package com.eurabia.eggchat.service.impl;

import com.eurabia.eggchat.enums.ResultEnum;
import com.eurabia.eggchat.enums.SportConstantEnum;
import com.eurabia.eggchat.exception.SportException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.eurabia.eggchat.pojo.SysEggchatSport;
import com.eurabia.eggchat.pojo.form.SysEggchatSportForm;
import com.eurabia.eggchat.pojo.query.SysEggchatSportQuery;
import com.eurabia.eggchat.dao.SysEggchatSportDao;
import com.eurabia.eggchat.service.SysEggchatSportService;

import javax.annotation.Resource;


/**
 * SysEggchatSportService 
 */
@Service
@Slf4j
public class SysEggchatSportServiceImpl implements SysEggchatSportService {
    @Resource
    private SysEggchatSportDao sysEggchatSportDao;
	
	/**
     * 查询 SysEggchatSport
     */
    @Override
    public List<SysEggchatSport> find(final SysEggchatSportQuery query) {
        return sysEggchatSportDao.find(query);
    }
    
    /**
     * 分页查询 SysEggchatSport
     */
    @Override
    public Page<SysEggchatSport> findByPage(final SysEggchatSportQuery query) {
        PageHelper.startPage(query.getPage().intValue(), query.getLimit().intValue());
        return (Page<SysEggchatSport>) sysEggchatSportDao.find(query);
    }

    /**
     * 通过id得到一个 SysEggchatSport
     */
    @Override
    public SysEggchatSport get(final String id) {

        SysEggchatSport sysEggchatSport = sysEggchatSportDao.get(id);
        if(sysEggchatSport == null)
        {
            log.info("数据不存在");
            throw new SportException(ResultEnum.DATA_NO_EXIST.getCode(),ResultEnum.DATA_NO_EXIST.getMessage());
        }
        return sysEggchatSport;
        /*return sysEggchatSportDao.get(id);*/
    }
    
    /**
     * 新增 SysEggchatSport
     */
    @Override
    public void add(final SysEggchatSportForm form) {
        sysEggchatSportDao.add(form);
    }

    /**
     * 修改 SysEggchatSport
     */
    @Override
    public int update(final SysEggchatSportForm form) {
        return sysEggchatSportDao.update(form);
    }
    
    /**
     * 删除一个 SysEggchatSport
     */
    @Override
    public int delete(final String id) {
        return sysEggchatSportDao.delete(id);
    }
	
	/**
     * 修改是否可用
     */
    @Override
    public int changeEnabled(final String id, final Integer enabled) {
        return sysEggchatSportDao.changeEnabled(id, enabled);
    }
}